import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, DelDataButton } from '../Common/options'
import { BimFilesConversion } from '../Common/Conversion'

export const BimFileOrganizationRelation = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const bimFilesUuid = await BimFilesConversion(ClientData.project)
    let data = {
        type: '模型进度',
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === 'b8d205c9-9fff-4ab2-b66e-43920b0df299') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增模型关系" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'bimFilesUuid',
                title: '模型',
                valueType: 'select',
                valueEnum: bimFilesUuid,
                rules: true,
                width: 200,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'd3522499-d0af-4f52-b3ff-2aaa5aef5209') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
